Skip to content

refactor: retire function-keyword in favor of arrow/method syntax (reconstruct #474 on current master) - #589

Draft
kriscendobot wants to merge 19 commits into
master-2708cacfrom
chore/retire-function-keyword-v2
Draft

refactor: retire function-keyword in favor of arrow/method syntax (reconstruct #474 on current master)#589
kriscendobot wants to merge 19 commits into
master-2708cacfrom
chore/retire-function-keyword-v2

Conversation

@kriscendobot

@kriscendobot kriscendobot commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Reconstructs endojs/endo-but-for-bots#474
(refactor: retire function-keyword in favor of arrow/method syntax per erights review, merged)
on the current upstream endojs/endo master, rather than cherry-picking #474's commits onto a
stale base.

Per erights's review, function-keyword functions carry four hazards inside hardened-JavaScript code
(they have [[Construct]], an irrelevant prototype, freezeharden, and declaration hoisting/TDZ
hazards). Arrow functions and concise methods have none of these and are the desired default. This PR
converts function-keyword declarations/expressions to arrow / concise-method syntax across the same
package set #474 covered, keeps the documented legitimate exceptions, and (re)establishes the house-style
convention doc.

How this differs from the merged #474

  • Re-applied to the current tree, not cherry-picked. The base here is the current upstream master
    snapshot (master-0594e99). The transformation was re-derived against that tree; where a conversion had
    already been absorbed upstream (e.g. pass-style/src/byteArray.js, passStyleOf.js), the net change is
    zero and the file simply does not appear in this PR.
  • Same scope as refactor: retire function-keyword in favor of arrow/method syntax per erights review #474. 17 packages, ~93 sites, plus the follow-up refinements that landed on refactor: retire function-keyword in favor of arrow/method syntax per erights review #474's
    branch (BaseHandledPromise rename, concise generator methods in captp/daemon, the init
    AsyncLocalStorage descriptor-form install, and the cross-reference notes at exception sites).
  • House-style doc. docs/house-style/function-keyword.md is present and current (rationale, conversion
    rules, and the full legitimate-exception list), linked from AGENTS.md.

Legitimate exceptions kept (unchanged from #474)

Constructor emulation (BaseHandledPromise, NewCompartment, SES inert constructors, ModuleSource/
AbstractModuleSource), standalone generator/async-generator expressions and intrinsic-prototype
sentinels (trampoline, ses/commons.js, compartment-mapper, daemon), vendored/third-party code
(cjs-module-analyzer, test262), the sloppy-mode getThis probe, TS-assertion-via-arrow+@overload,
and module-init forward references (convertValToSlot/convertSlotToVal, serializeAndSendMessage,
safeRequire). See the house-style doc for the full rationale.

Out of scope (follow-up)

An audit of the current tree surfaced further un-migrated function-keyword sites in SES files that
#474 never touched — the lockdown/taming dispatch functions (tame-*.js), permits-intrinsics.js,
permits.js, enable-property-overrides.js, make-evaluate.js, and SES's own make-hardener.js. These
are outside #474's original scope and several sit on the security-critical SES initialization boundary, so
they are deliberately left for a separate, individually-reviewed pass rather than folded into this
reconstruction.

Verification

  • eslint on all changed files: 0 errors (4 pre-existing-style jsdoc/require-param warnings on the
    converted daemon generator methods, identical to refactor: retire function-keyword in favor of arrow/method syntax per erights review #474's merged form; non-fatal).
  • node --check on every changed file: clean.
  • Package test spot-checks (zip, trampoline, eventual-send): green. The conversion preserves arity,
    return value, and this binding — the intended behavioral diff is zero.
  • Full build/tsc/test runs via CI.

Upstream counterpart

The canonical upstream PR for this work is endojs/endo#3312
(refactor: retire function-keyword in favor of arrow/method syntax, OPEN). This fork PR mirrors #3312's
transformation; the head tree here is identical to #3312's, rebased onto a fresh frozen base
(master-2708cac, a snapshot of the current upstream endojs/endo master). The earlier boatman-created
duplicate #3318 is closed and is not tracked.

@kriscendobot

Copy link
Copy Markdown
Collaborator Author

Reconstruction of #474 on current upstream master is up.

Scope — reproduces #474's function-keyword→arrow/concise-method conversion across the same 17 packages
(~93 sites) plus #474's on-branch follow-ups (BaseHandledPromise rename, captp/daemon concise generator
methods, init AsyncLocalStorage descriptor-form install, exception-site cross-references), and
(re)establishes docs/house-style/function-keyword.md linked from AGENTS.md. Base is the frozen current
upstream master snapshot master-0594e99.

How it differs from merged #474 — re-derived against the current tree, not cherry-picked. Conversions
already absorbed upstream (pass-style/byteArray.js, passStyleOf.js) are net-zero and absent here.
Net: 55 files, +865/−533.

Deliberately out of scope — the audit surfaced further un-migrated sites in SES files #474 never
touched (tame-*.js lockdown dispatch, permits-intrinsics.js, permits.js,
enable-property-overrides.js, SES's own make-hardener.js). Several sit on the security-critical SES
init boundary, so they are left for a separate individually-reviewed pass.

Verificationeslint on all changed files: 0 errors (4 non-fatal jsdoc/require-param warnings on
the converted daemon generator methods, identical to #474's merged form). node --check clean on every
file. Package test spot-checks (zip, trampoline, eventual-send) green; behavioral diff is zero by
construction (arity/return/this preserved). Full build/tsc/test via CI (running now).

@kriskowal

Copy link
Copy Markdown
Member

Mirror of endojs/endo#3318 (head b25a1b6e2).

kriscendobot pushed a commit to kriscendobot/garden that referenced this pull request Jul 4, 2026
@kriscendobot

Copy link
Copy Markdown
Collaborator Author

On it — I've posted a job (endojs-endo-but-for-bots-pr589-8f67c6ab) and will follow up here when it lands.

@kriscendobot

Copy link
Copy Markdown
Collaborator Author

Mirror parity verified against endojs/endo#3318 (head b25a1b6e2).

Compared this PR's diff to endo#3318's at that head:

  • File set — identical: the same 55 files change in both, with zero divergence in either direction.
  • Content — the added/removed lines match byte-for-byte across all 55 files (diff-of-diffs is empty).

No changes needed — this reconstruction is a faithful mirror of endo#3318 at b25a1b6e2. The two differ only in base (this PR sits on the frozen master-0594e99 snapshot; endo#3318 sits on live master), which does not affect the transformation.

endolinbot added 19 commits July 16, 2026 23:30
Add the house-style doc for arrow and concise-method syntax over the
function keyword (rationale, hardened-JS hazards, exception categories)
and link it from AGENTS.md. Reconstructs the doc from #474.
@kriscendobot
kriscendobot force-pushed the chore/retire-function-keyword-v2 branch from a97452b to 4f14a7f Compare July 16, 2026 23:31
@kriscendobot
kriscendobot changed the base branch from master-0594e99 to master-2708cac July 16, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants